import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { HeroService } from '../../../../services/hero.service';
import { NzModalService } from 'ng-zorro-antd';

@Component({
  selector: 'app-taskinfo',
  templateUrl: './taskinfo.component.html',
  styleUrls: ['./taskinfo.component.css']
})
export class TaskinfoComponent implements OnInit {

  public maintinfo:Array<any>=[''];
  public userinfo:Array<any>=[''];
  public taskinfo:Array<any>=[''];
  public tasklist:Array<any>=[];
  public PageIndex:number=1;
  public PageSize:number=6;
  public PageTotal:number;
  constructor(private heroService: HeroService,
              private route: ActivatedRoute,
              private modalService: NzModalService) { }

  ngOnInit() {
    this.getTaskinfo(true);
  }

  //获取工单详情数据
  getTaskinfo(getInfo){
    const id= this.route.snapshot.params["id"]; 
    let url=host+"/main/merchantTaskOrder/view?id="+id+"&getInfo="+getInfo+"&page="+this.PageIndex+"&pageSize="+this.PageSize;
    this.heroService.get(url).then(result=>{
      if(result.code==0){
        this.taskinfo[0]=result.data.bean;
        this.maintinfo[0]=result.data.connectMaint;
        this.userinfo[0]=result.data.connectUser;
        this.tasklist=result.data.TaskInfo.pageBean.result;
        this.PageIndex=result.data.TaskInfo.pageBean.curPage;
        this.PageTotal=result.data.TaskInfo.pageBean.totalRow;
      }else{
        this.modalService.error({
          nzTitle: '提示',
          nzContent: result.msg
        });
      }
    })
  }

   //分页
  PageIndexChange(event){
    this.PageIndex=event;
    this.getTaskinfo(false);
  }
}
